<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="../vue.js"></script>
</head>
<body>

	<div id="app">
		<child content="Mr"></child>
		<child content="Seven"></child>
	</div>

	<script>

		Vue.prototype.bus = new Vue();

		Vue.component('child', {
			props: {
				content: String
			},
			data: function () {
				return {
					name: this.content
				}
			},
			template: '<div @click="handleClick">{{name}}</div>',
			methods: {
				handleClick: function () {
					this.bus.$emit('change', this.name);
				}
			},
			mounted: function () {
				var _this = this;
				this.bus.$on('change', function (msg) {
					_this.name = msg;
				})
			}
		});

		var vm = new Vue({
			el: '#app',
		});

	</script>
</body>
</html>